import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import path from 'path'
//引入element-plus 自动导入插件  按需导入
// import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx(), vueSetupExtend(),
  // AutoImport({
  //   resolvers: [ElementPlusResolver()],
  // }), 
  Components({
    resolvers: [ElementPlusResolver()],
  })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import "@/assets/scss/variables.scss";',
        javascriptEnabled: true
      }
    }
  },
  server: {
    proxy: {
      "/api": {
        target: 'http://192.168.137.1:3000',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      },
    } 
  } 
})
 